<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let input =`mkdir abc
        
cd abc
mkdir a
cd a
mkdir b
cd b
Pwd`

        let spl=input.split('\n').map(v=>v.trim())

        class Node{ 
         
            constructor(dir){
                this.dir=dir
                this.father=null
                this.childrens={}
            }      

             addChild(newdir,fathernode){
                if(this.childrens[newdir]){
                    return
                }else{
                    for(let char of newdir){
                        if(char<'a'||char>'z'){
                            return
                        }
                    }                    
                    let newnode=new Node()
                    this.childrens[newdir]=newnode
                    newnode.father=fathernode
                    newnode.dir=newdir
                }
            }               
            pwd(nowNode){                          
                let str=[nowNode.dir]
              let   t=nowNode.father
                while(t!==null){
                    str.push(t.dir)                    
                    t=t.father
                }
                console.log(str.reverse().join('/')+'/');                
            }
            getCd(str,nowNode){
                if(str==='..'&&nowNode.father){
                    return nowNode.father
                }
                for(let char of str){
                        if(char<'a'||char>'z'){
                            return nowNode
                        }
                    }                    
                if(nowNode.childrens[str]){
                    return nowNode.childrens[str]

                }else{
                    return nowNode
                }
            }

                      
        }
        let node=new Node()

        for(let i=0;i<spl.length;i++){

            let [x,y]=spl[i].split(' ')
            
            if(x==='mkdir'){
                node.addChild(y,node)
            }
            if(x==='cd'){
                node=node.getCd(y,node)               
            }
            if(x==='Pwd'){
                node.pwd(node)
            }
        }

    </script>
</body>
</html>